package cn.iocoder.yudao.module.member.controller.admin.siteconfig;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.member.controller.admin.siteconfig.vo.SiteConfigurationVo;
import cn.iocoder.yudao.module.member.controller.admin.siteconfig.vo.UserPoolConfigVo;
import cn.iocoder.yudao.module.member.service.siteconfiguration.SiteConfigurationService;
import cn.iocoder.yudao.module.member.service.siteconfiguration.UserPoolConfigService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

import java.util.List;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

@Tag(name = "管理后台 - 前端站点池配置")
@RestController
@RequestMapping("/member/user/pool/configuration")
@Validated
public class UserPoolConfigController {

    @Resource
    private UserPoolConfigService userPoolConfigService;

    @GetMapping("/get")
    @Operation(summary = "")
    @PreAuthorize("@ss.hasPermission('member:user:pool:configuration:get')")
    public CommonResult<List<UserPoolConfigVo>> getConfig() {
        List<UserPoolConfigVo> config = userPoolConfigService.getConfig();
        return success(config);
    }

    /**
     * 单独修改配置信息
     * @return
     */
    @PostMapping("/update")
    @Operation(summary = "单独修改配置")
    @PreAuthorize("@ss.hasPermission('member:user:pool:configuration:update')")
    public CommonResult<T> updateConfig(@RequestBody UserPoolConfigVo vo) {
        userPoolConfigService.updateConfig(vo);
        return success(null);
    }
}
